import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Numbers {
	private static class Surd {
		BigInteger a, b, c; // a + b * sqrt(c)
		public Surd(BigInteger a, BigInteger b, BigInteger c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}
		public Surd pow(int n) {
			Surd p = new Surd(BigInteger.ONE, BigInteger.ZERO, c);
			long m = 0x8000;
			while(m > 0) {
				p = p.multiply(p);
				if((n & m) > 0)
					p = p.multiply(this);
				m = m >> 1;
			}
			return p;
		}
		/**
		 * assumes this.c and surd.c are same
		 * @param surd
		 * @return
		 */
		public Surd multiply(Surd surd) {
			assert c == surd.c;
			return new Surd(a.multiply(surd.a).add(b.multiply(surd.b).multiply(c)), a.multiply(surd.b).add(b.multiply(surd.a)), c);
		}
		/**
		 * c is assumed to be 5
		 * @return
		 */
		public BigDecimal value() {
			return new BigDecimal(a.toString()).add(new BigDecimal(b.toString()).multiply(new BigDecimal("2.23606797749978969640917366873127623544061835961152572427089")));
		}
	}
	private static String toString(long n, int d) {
		String s = "" + n;
		while(s.length() < d)
			s = "0" + s;
		return s;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
		try {
			int T = Integer.parseInt(rdr.readLine());
			for(int t = 1; t <= T; t++) {
				int n = Integer.parseInt(rdr.readLine());
				Surd r = new Surd(new BigInteger("3"), BigInteger.ONE, new BigInteger("5")).pow(n);
				BigDecimal v = r.value();
				long lv = v.remainder(new BigDecimal(1000)).longValue();
				System.out.println("Case #" + t + ": " + toString(lv, 3));
			}
		} finally {
			rdr.close();
		}
	}
}
